<template>
   <div>
      <el-date-picker class="highly"
         v-model="value"
         type="date"
         placeholder="选择日期搜索"
         value-format="yyyy-MM-dd"
         @change="searchLogs(value)"
      >
      </el-date-picker>

      <el-table :data="getLogs" style="width: 100%">
         <el-table-column type="index" label="编号"> </el-table-column>
         <el-table-column prop="address" label="日志地址"> </el-table-column>
         <el-table-column prop="name" label="日志用户名"> </el-table-column>
         <el-table-column prop="time" label="日志时间"> </el-table-column>
         <el-table-column  prop="operation" label="日志操作" ></el-table-column>
         <el-table-column prop="result" label="执行结果"> </el-table-column>
      </el-table>
      <el-pagination
         @size-change="handleSizeChange"
         @current-change="handleCurrentChange"
         :current-page="currentPage"
         :page-sizes="[2, 4, 5, 7]"
         :page-size="pageSize"
         layout="total, sizes, prev, pager, next, jumper"
         :total="total"
      >
      </el-pagination>
   </div>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
const { mapState, mapMutations, mapActions } = createNamespacedHelpers("logs");
export default {
   data() {
      return {
         value: "",
      };
   },
   watch: {
      currentPage() {
         this.getLogsdata(this.value);
      },
      pageSize() {
         this.getLogsdata(this.value);
      },
      value() {
         this.getLogsdata(this.value);
      },
   },
   mounted() {
      this.getLogsdata(this.value);
   },
   computed: {
      ...mapState(["getLogs", "total", "pageSize", "currentPage"]),
      number() {
         return this.getLogs.length;
      },
   },
   methods: {
      ...mapMutations(["changePageSize", "changeCurrentPage", "serialNumber",'changeCurrentPageToFirst']),
      ...mapActions(["getLogsdata", "timeSearchLogsdata"]),
      handleSizeChange(val) {
         this.changePageSize(val);
      },
      handleCurrentChange(val) {
         this.changeCurrentPage(val);
      },
      onSubmit() {
         console.log("submit!");
      },
      searchLogs(value){
          this.changeCurrentPageToFirst();
          this.getLogsdata(value + '')
      }
   },
};
</script>

<style>
</style>